import {getProperty} from './config'
import internetAvailable from 'internet-available'

let host = getProperty("isOnlineHost")

/**
 * 判断是否联网中
 */
export function isOnline() {
    let promise = new Promise(function (resolve, reject) {
        internetAvailable({
            timeout: 4000,
            retries: 2,
            host: host
        }).then(() => {
            resolve(true);
        }).catch(() => {
            resolve(false)
        });
    });

    return promise
}